﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using MODEL;
using DBUtility;

namespace DAL
{
    /// <summary>
    /// 用户登录
    /// </summary>
    public class UserLogon
    {
        public UserLogon()
        { }
        /// <summary>
        /// 用户账户 注册
        /// </summary>
        /// <param name="model">注册实体</param>
        /// <returns>是否执行成功</returns>
        public bool UserLogonAdd(MODEL.UserLogon model)
        {
            SqlParameter[] parameter ={new SqlParameter("@id",SqlDbType.VarChar,15),
                                       new SqlParameter("@username",SqlDbType.VarChar,50),
                                       new SqlParameter("@password",SqlDbType.VarChar,100),
                                       new SqlParameter("@previp",SqlDbType.VarChar,15),
                                       new SqlParameter("@logonip",SqlDbType.VarChar,15),
                                       new SqlParameter("@prevtime",SqlDbType.DateTime),
                                       new SqlParameter("@logontime",SqlDbType.DateTime),
                                       new SqlParameter("@state",SqlDbType.Bit),
                                       new SqlParameter("@Return",SqlDbType.Int)};
            parameter[0].Value = model.UID;
            parameter[1].Value = model.UlogonName;
            parameter[2].Value = model.UpassWord;
            parameter[3].Value = model.UprevIP;
            parameter[4].Value = model.UlogonIP;
            parameter[5].Value = model.UprevTime;
            parameter[6].Value = model.UlogonTime;
            parameter[7].Value = model.Ustate;
            for (int i = 0; i < 8; i++)
            {
                parameter[i].Direction = ParameterDirection.Input;
            }
            parameter[8].Direction = ParameterDirection.ReturnValue;
            return DbHelper.RunProcedure("ProUserlogonAdd", parameter);

        }
        /// <summary>
        /// 用户账户 停用
        /// </summary>
        /// <param name="uId">用户编号</param>
        /// <returns>是否执行成功</returns>
        public bool UserLogonDel(string uId)
        {
            SqlParameter[] parameter ={new SqlParameter("@id",SqlDbType.VarChar,15),
                                       new SqlParameter("@Return",SqlDbType.Int)};
            parameter[0].Value = uId;
            parameter[0].Direction = ParameterDirection.Input;
            parameter[1].Direction = ParameterDirection.ReturnValue;
            return DbHelper.RunProcedure("ProUserlogonDelete", parameter);
        }
        /// <summary>
        /// 用户账户 修改密码
        /// </summary>
        /// <param name="model">信息实体</param>
        /// <returns>是否执行成功</returns>
        public bool UserLogonUpdatePassword(MODEL.UserLogon model)
        {
            SqlParameter[] parameter ={new SqlParameter("@id",SqlDbType.VarChar,15),
                                       new SqlParameter("@password",SqlDbType.VarChar,100),
                                       new SqlParameter("@Return",SqlDbType.Int)};
            parameter[0].Value = model.UID;
            parameter[0].Direction = ParameterDirection.Input;
            parameter[1].Value = model.UpassWord;
            parameter[1].Direction = ParameterDirection.Input;
            parameter[2].Direction = ParameterDirection.ReturnValue;
            return DbHelper.RunProcedure("ProUserlogonUpdatePassword", parameter);
        }
        /// <summary>
        /// 用户账户 账户激活
        /// </summary>
        /// <param name="userId">用户编号</param>
        /// <param name="regTime">注册时间</param>
        /// <returns>激活是否成功</returns>
        public bool UserLogonUpdateState(string userId, string logonIp)
        {
            SqlParameter[] parameter ={new SqlParameter("@id",SqlDbType.VarChar,15),
                                       new SqlParameter("@ip",SqlDbType.VarChar,15),
                                       new SqlParameter("@Return",SqlDbType.Int)};
            parameter[0].Value = userId;
            parameter[0].Direction = ParameterDirection.Input;
            parameter[1].Value = logonIp;
            parameter[1].Direction = ParameterDirection.Input;
            parameter[2].Direction = ParameterDirection.ReturnValue;
            return DbHelper.RunProcedure("ProUserlogonUpdateState", parameter);
        }
        /// <summary>
        /// 用户账户 登录
        /// </summary>
        /// <param name="model">登录信息实体</param>
        /// <returns>是否验证成功</returns>
        public bool UserLogonCheck(MODEL.UserLogon model)
        {
            SqlParameter[] parameter ={new SqlParameter("@username",SqlDbType.VarChar,50),
                                       new SqlParameter("@password",SqlDbType.VarChar,100),
                                       new SqlParameter("@logonip",SqlDbType.VarChar,15),
                                       new SqlParameter("@Return",SqlDbType.Int)};
            parameter[0].Value = model.UlogonName;
            parameter[0].Direction = ParameterDirection.Input;
            parameter[1].Value = model.UpassWord;
            parameter[1].Direction = ParameterDirection.Input;
            parameter[2].Value = model.UlogonIP;
            parameter[2].Direction = ParameterDirection.Input;
            parameter[3].Direction = ParameterDirection.ReturnValue;
            return DbHelper.RunProcedure("ProUserlogonSelectByNameANDPass", parameter);
        }
        /// <summary>
        /// 用户账户 列表
        /// </summary>
        /// <returns>列表</returns>
        public DataSet UserLogonList()
        {
            return DbHelper.RunProcedure("ProUserlogonSelectALL");
        }
        /// <summary>
        /// 用户账户 实体
        /// </summary>
        /// <param name="uId">用户编号</param>
        /// <returns>实体</returns>
        public MODEL.UserLogon GetUserLogonModel(string uId)
        {
            SqlParameter[] parameter = { new SqlParameter("@id", SqlDbType.VarChar, 15) };
            parameter[0].Value = uId;
            parameter[0].Direction = ParameterDirection.Input;
            MODEL.UserLogon model = new MODEL.UserLogon();
            DataSet ds = DbHelper.RunProcedureS("ProUserlogonSelectByID", parameter);
            if (ds.Tables[0].Rows.Count > 0)
            {
                model.UID = ds.Tables[0].Rows[0]["Uid"].ToString();
                model.UlogonIP = ds.Tables[0].Rows[0]["Ulogonip"].ToString();
                model.UlogonName = ds.Tables[0].Rows[0]["UlogonName"].ToString();
                model.UlogonTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["UlogonTime"]);
                model.UpassWord = ds.Tables[0].Rows[0]["UpassWord"].ToString();
                model.UprevIP = ds.Tables[0].Rows[0]["Uprevip"].ToString();
                model.UprevTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["UprevTime"]);
                model.Uregtime = Convert.ToDateTime(ds.Tables[0].Rows[0]["Uregtime"]);
                model.Ustate = Convert.ToBoolean(ds.Tables[0].Rows[0]["Ustate"]);
            }
            else
            {
                model = null;
            }
            return model;
        }
        /// <summary>
        /// 用户账户 列表
        /// </summary>
        /// <param name="userState">用户状态</param>
        /// <returns>列表</returns>
        public DataSet UserLogonList(bool userState)
        {
            SqlParameter[] parameter = { new SqlParameter("@state", SqlDbType.Bit) };
            parameter[0].Value = userState;
            parameter[0].Direction = ParameterDirection.Input;
            return DbHelper.RunProcedureS("ProUserlogonSelectByState", parameter);
        }
        /// <summary>
        /// 用户账户 列表
        /// </summary>
        /// <param name="userName">用户名称</param>
        /// <returns>列表</returns>
        public DataSet UserLogonList(string userName)
        {
            SqlParameter[] parameter = { new SqlParameter("@username", SqlDbType.VarChar, 50) };
            parameter[0].Value = userName;
            parameter[0].Direction = ParameterDirection.Input;

            return DbHelper.RunProcedureS("ProUserlogonSelectState", parameter);
        }
        /// <summary>
        /// 用户账户 检索用户名是否可用
        /// </summary>
        /// <param name="userName">用户名称</param>
        /// <returns>列表</returns>
        public DataSet UserNameCheck(string userName)
        {
            SqlParameter[] parameter = { new SqlParameter("@name", SqlDbType.VarChar, 50) };
            parameter[0].Value = userName;
            parameter[0].Direction = ParameterDirection.Input;
            return DbHelper.RunProcedureS("ProUserlogonSelectByName", parameter);
        }
        /// <summary>
        /// 用户账户 查询用户编号
        /// </summary>
        /// <param name="userName">用户名称</param>
        /// <returns>列表</returns>
        public DataSet UserLogonListByName(string userName)
        {
            SqlParameter[] parameter = { new SqlParameter("@name", SqlDbType.VarChar, 50) };
            parameter[0].Value = userName;
            parameter[0].Direction = ParameterDirection.Input;
            return DbHelper.RunProcedureS("ProUserlogonSelectIDByName", parameter);
        }
        /// <summary>
        /// 用户账户 获取最大编号
        /// </summary>
        /// <returns>最大编号</returns>
        public string GetMaxId()
        {
            string maxId = string.Empty;
            string timeNum=DateTime.Now.ToString("yyyyMMdd");
            string sqlStr = "select max(uid) as id from g_userlogon where uid like '"+timeNum+"%'";
            DataSet ds = DbHelper.Query(sqlStr);
            if (ds.Tables[0].Rows[0][0].ToString() == "" || ds.Tables[0].Rows[0][0] == null)
            {
                maxId = DateTime.Now.ToString("yyyyMMdd") + "001";
            }
            else
            {
                int i = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString().Substring(8, 3)) + 1;
                maxId = DateTime.Now.ToString("yyyyMMdd") + string.Format("{0:D3}", i);
            }
            return maxId;
        }
        /// <summary>
        /// 用户账户 验证用户名密码
        /// </summary>
        /// <param name="model">用户实体</param>
        /// <returns>验证是否成功</returns>
        public bool CheckPassword(MODEL.UserLogon model)
        {
            SqlParameter[] parameter ={new SqlParameter("@name",SqlDbType.VarChar,50),
                                       new SqlParameter("@pwd",SqlDbType.VarChar,100),
                                       new SqlParameter("@Return",SqlDbType.Int)};
            parameter[0].Value = model.UlogonName;
            parameter[0].Direction = ParameterDirection.Input;
            parameter[1].Value = model.UpassWord;
            parameter[1].Direction = ParameterDirection.Input;
            parameter[2].Direction = ParameterDirection.ReturnValue;
            return DbHelper.RunProcedure("ProCheckUserNameAndPassword", parameter);
        }

    }
    /// <summary>
    /// 密码保护
    /// </summary>
    public class UserPassSafeGuard
    {
        public UserPassSafeGuard()
        { }
        /// <summary>
        /// 密码保护 设置
        /// </summary>
        /// <param name="model">密码保护实体</param>
        /// <returns>是否执行成功</returns>
        public bool UserPassSafeGuardAdd(MODEL.UserPassSafeguard model)
        {
            SqlParameter[] parameter ={new SqlParameter("@uid",SqlDbType.VarChar,15),
                                       new SqlParameter("@questionid",SqlDbType.Int),
                                       new SqlParameter("@answer",SqlDbType.Text),
                                       new SqlParameter("@Return",SqlDbType.Int)};
            parameter[0].Value = model.UID;
            parameter[0].Direction = ParameterDirection.Input;
            parameter[1].Value = model.UquestionID;
            parameter[1].Direction = ParameterDirection.Input;
            parameter[2].Value = model.Uanswer;
            parameter[2].Direction = ParameterDirection.Input;
            parameter[3].Direction = ParameterDirection.ReturnValue;
            return DbHelper.RunProcedure("ProUserpasssafeguardAdd", parameter);
        }
        /// <summary>
        /// 密码保护 修改
        /// </summary>
        /// <param name="model">密码保护实体</param>
        /// <returns>是否执行成功</returns>
        public bool UserPassSafeGuardUpdate(MODEL.UserPassSafeguard model)
        {
            SqlParameter[] parameter ={new SqlParameter("@id",SqlDbType.Int),
                                       new SqlParameter("@uid",SqlDbType.VarChar,15),
                                       new SqlParameter("@questionid",SqlDbType.Int),
                                       new SqlParameter("@answer",SqlDbType.Text),
                                       new SqlParameter("@Return",SqlDbType.Int)};
            parameter[0].Value = model.ID;
            parameter[0].Direction = ParameterDirection.Input;
            parameter[1].Value = model.UID;
            parameter[1].Direction = ParameterDirection.Input;
            parameter[2].Value = model.UquestionID;
            parameter[2].Direction = ParameterDirection.Input;
            parameter[3].Value = model.Uanswer;
            parameter[3].Direction = ParameterDirection.Input;
            parameter[4].Direction = ParameterDirection.ReturnValue;
            return DbHelper.RunProcedure("ProUserpasssafeguardUpdate", parameter);
        }
        /// <summary>
        /// 密码保护 密保列表
        /// </summary>
        /// <param name="uId">用户编号</param>
        /// <returns>列表</returns>
        public DataSet UserPassSafeGuardList(string uId)
        {
            SqlParameter[] parameter = { new SqlParameter("@id", SqlDbType.VarChar, 15) };
            parameter[0].Value = uId;
            parameter[0].Direction = ParameterDirection.Input;
            return DbHelper.RunProcedureS("ProUserpasssafeguardSelectByUid", parameter);
        }
        /// <summary>
        /// 密码保护 验证密保
        /// </summary>
        /// <param name="model">密码保护实体</param>
        /// <returns>密保是否正确</returns>
        public bool UserPassSafeGuardCheck(MODEL.UserPassSafeguard model)
        {
            SqlParameter[] parameter ={new SqlParameter("@uid",SqlDbType.VarChar,15),
                                        new SqlParameter("@questionid",SqlDbType.Int),
                                        new SqlParameter("@answer",SqlDbType.Text),
                                        new SqlParameter("@Return",SqlDbType.Int)};
            parameter[0].Value = model.UID;
            parameter[0].Direction = ParameterDirection.Input;
            parameter[1].Value = model.UquestionID;
            parameter[1].Direction = ParameterDirection.Input;
            parameter[2].Value = model.Uanswer;
            parameter[2].Direction = ParameterDirection.Input;
            parameter[3].Direction = ParameterDirection.ReturnValue;
            return DbHelper.RunProcedure("ProUserpasssafeguardCheck", parameter);
        }
    }
    /// <summary>
    /// 密保问题
    /// </summary>
    public class UserQuestion
    {
        public UserQuestion()
        { }
        /// <summary>
        /// 密保问题 添加
        /// </summary>
        /// <param name="model">密保实体</param>
        /// <returns>是否执行成功</returns>
        public bool UserQuestionAdd(MODEL.UserQuestion model)
        {
            SqlParameter[] parameter ={new SqlParameter("@question",SqlDbType.VarChar,200),
                                       new SqlParameter("@state",SqlDbType.Bit),
                                       new SqlParameter("@Return",SqlDbType.Int)};
            parameter[0].Value = model.Uquestion;
            parameter[0].Direction = ParameterDirection.Input;
            parameter[1].Value = model.Ustate;
            parameter[1].Direction = ParameterDirection.Input;
            parameter[2].Direction = ParameterDirection.ReturnValue;
            return DbHelper.RunProcedure("ProUserquestionAdd", parameter);
        }
        /// <summary>
        /// 密保问题 删除
        /// </summary>
        /// <param name="questionId">密保编号</param>
        /// <returns>是否执行成功</returns>
        public bool UserQuestionDel(int questionId)
        {
            SqlParameter[] parameter ={new SqlParameter("@id",SqlDbType.Int),
                                       new SqlParameter("@Return",SqlDbType.Int)};
            parameter[0].Value = questionId;
            parameter[0].Direction = ParameterDirection.Input;
            parameter[1].Direction = ParameterDirection.ReturnValue;
            return DbHelper.RunProcedure("ProUserquestionDelete", parameter);
        }
        /// <summary>
        /// 密保问题 列表
        /// </summary>
        /// <returns>列表</returns>
        public DataSet UserQuestionList()
        {
            return DbHelper.RunProcedure("ProUserquestionSelectAll");
        }
        /// <summary>
        /// 密保问题 列表
        /// </summary>
        /// <param name="questionId">密保编号</param>
        /// <returns>列表</returns>
        public DataSet UserQuestionList(int questionId)
        {
            SqlParameter[] parameter = { new SqlParameter("@id", SqlDbType.Int) };
            parameter[0].Value = questionId;
            parameter[0].Direction = ParameterDirection.Input;
            return DbHelper.RunProcedureS("ProUserquestionSelectByID", parameter);
        }
        /// <summary>
        /// 密保问题 列表
        /// </summary>
        /// <param name="questionState">问题状态</param>
        /// <returns>列表</returns>
        public DataSet UserQuestionList(bool questionState)
        {
            SqlParameter[] parameter = { new SqlParameter("@state", SqlDbType.Bit) };
            parameter[0].Value = questionState;
            parameter[0].Direction = ParameterDirection.Input;
            return DbHelper.RunProcedureS("ProUserquestionSelectByState", parameter);
        }
        /// <summary>
        /// 密保问题 内容
        /// </summary>
        /// <param name="questionId">密保编号</param>
        /// <returns>内容</returns>
        public string UserQuestionById(int questionId)
        {
            SqlParameter[] parameter = { new SqlParameter("@id", SqlDbType.Int),
                                         new SqlParameter("@return",SqlDbType.VarChar,200)};
            parameter[0].Value = questionId;
            parameter[0].Direction = ParameterDirection.Input;
            parameter[1].Direction = ParameterDirection.ReturnValue;
            return DbHelper.RunProcedureString("ProUserquestionSelectByIDReturnQuestion", parameter);
        }
    }
    /// <summary>
    /// 用户消费
    /// </summary>
    public class UserConsumotion
    {
        public UserConsumotion()
        { }
        /// <summary>
        /// 用户消费 添加
        /// </summary>
        /// <param name="model">用户消费实体</param>
        /// <returns>是否执行成功</returns>
        public bool UserConsumotionAdd(MODEL.UserConsumotion model)
        {
            SqlParameter[] parameter ={new SqlParameter("@uid",SqlDbType.VarChar,15),
                                       new SqlParameter("@orderid",SqlDbType.VarChar,20),
                                       new SqlParameter("@begintime",SqlDbType.DateTime),
                                       new SqlParameter("@endtime",SqlDbType.DateTime),
                                       new SqlParameter("@isover",SqlDbType.Bit),
                                       new SqlParameter("@Return",SqlDbType.Int)};
            parameter[0].Value = model.UID;
            parameter[0].Direction = ParameterDirection.Input;
            parameter[1].Value = model.UorderID;
            parameter[1].Direction = ParameterDirection.Input;
            parameter[2].Value = model.UcreateTime;
            parameter[2].Direction = ParameterDirection.Input;
            parameter[3].Value = model.UoverTime;
            parameter[3].Direction = ParameterDirection.Input;
            parameter[4].Value = model.UisOver;
            parameter[4].Direction = ParameterDirection.Input;
            parameter[5].Direction = ParameterDirection.ReturnValue;
            return DbHelper.RunProcedure("ProUserconsumotionAdd", parameter);
        }
        /// <summary>
        /// 用户消费 修改
        /// </summary>
        /// <param name="model">用户消费实体</param>
        /// <returns>是否执行成功</returns>
        public bool UserConsumotionUpdate(MODEL.UserConsumotion model)
        {
            SqlParameter[] parameter ={new SqlParameter("@uid",SqlDbType.VarChar,15),
                                       new SqlParameter("@order",SqlDbType.VarChar,20),
                                       new SqlParameter("@endtime",SqlDbType.DateTime),
                                       new SqlParameter("@Return",SqlDbType.Int)};
            parameter[0].Value = model.UID;
            parameter[0].Direction = ParameterDirection.Input;
            parameter[1].Value = model.UorderID;
            parameter[1].Direction = ParameterDirection.Input;
            parameter[2].Value = model.UoverTime;
            parameter[2].Direction = ParameterDirection.Input;
            parameter[3].Direction = ParameterDirection.ReturnValue;
            return DbHelper.RunProcedure("ProUserconsumotionUpdate", parameter);
        }
        /// <summary>
        /// 用户消费 列表
        /// </summary>
        /// <returns>列表</returns>
        public DataSet UserConsumotionList()
        {
            return DbHelper.RunProcedure("ProUserconsumotionSelectAll");
        }
        /// <summary>
        /// 用户消费列表
        /// </summary>
        /// <param name="uId">用户编号</param>
        /// <returns>列表</returns>
        public DataSet UserConsumotionList(string uId)
        {
            SqlParameter[] parameter = { new SqlParameter("@uid", SqlDbType.VarChar, 15) };
            parameter[0].Value = uId;
            parameter[0].Direction = ParameterDirection.Input;
            return DbHelper.RunProcedureS("ProUserconsumotionSelectByUid", parameter);
        }
    }
    /// <summary>
    /// 用户游戏
    /// </summary>
    public class UserGameInformation
    {
        public UserGameInformation()
        { }
        /// <summary>
        /// 用户游戏 添加
        /// </summary>
        /// <param name="model">用户游戏实体</param>
        /// <returns>是否执行成功</returns>
        public bool UserGameInformationAdd(MODEL.UserGameInformation model)
        {
            SqlParameter[] parameter ={new SqlParameter("@uid",SqlDbType.VarChar,15),
                                       new SqlParameter("@gameid",SqlDbType.VarChar,20),
                                       new SqlParameter("@Return",SqlDbType.Int)};
            parameter[0].Value = model.UID;
            parameter[0].Direction = ParameterDirection.Input;
            parameter[1].Value = model.UgameID;
            parameter[1].Direction = ParameterDirection.Input;
            parameter[2].Direction = ParameterDirection.ReturnValue;
            return DbHelper.RunProcedure("ProUsergameinformationAdd", parameter);
        }
        /// <summary>
        /// 用户游戏 列表
        /// </summary>
        /// <returns>列表</returns>
        public DataSet UserGameInformationList()
        {
            return DbHelper.RunProcedure("ProUsergameinformationSelectAll");
        }
        /// <summary>
        /// 用户游戏 列表
        /// </summary>
        /// <param name="uId">用户编号</param>
        /// <returns>列表</returns>
        public DataSet UserGameInformationList(string uId)
        {
            SqlParameter[] parameter = { new SqlParameter("@uid", SqlDbType.VarChar, 15) };
            parameter[0].Value = uId;
            parameter[0].Direction = ParameterDirection.Input;
            return DbHelper.RunProcedureS("ProUsergameinformationSelectByUid", parameter);
        }
    }
    /// <summary>
    /// 用户信息
    /// </summary>
    public class UserInformation
    {
        public UserInformation()
        { }
        /// <summary>
        /// 用户信息 添加
        /// </summary>
        /// <param name="model">用户信息实体</param>
        /// <returns>执行是否成功</returns>
        public bool UserInformationAdd(MODEL.UserInformation model)
        {
            SqlParameter[] parameter ={new SqlParameter("@uid",SqlDbType.VarChar,15),
                                       new SqlParameter("@nickname",SqlDbType.VarChar,50),
                                       new SqlParameter("@sex",SqlDbType.Bit),
                                       new SqlParameter("@qq",SqlDbType.VarChar,20),
                                       new SqlParameter("@email",SqlDbType.VarChar,100),
                                       new SqlParameter("@tel",SqlDbType.VarChar,20),
                                       new SqlParameter("@province",SqlDbType.VarChar,20),
                                       new SqlParameter("@city",SqlDbType.VarChar,20),
                                       new SqlParameter("@Return",SqlDbType.Int)};
            parameter[0].Value = model.UID;
            parameter[0].Direction = ParameterDirection.Input;
            parameter[1].Value = model.UnickName;
            parameter[1].Direction = ParameterDirection.Input;
            parameter[2].Value = model.Usex;
            parameter[2].Direction = ParameterDirection.Input;
            parameter[3].Value = model.Uqq;
            parameter[3].Direction = ParameterDirection.Input;
            parameter[4].Value = model.Uemail;
            parameter[4].Direction = ParameterDirection.Input;
            parameter[5].Value = model.Utel;
            parameter[5].Direction = ParameterDirection.Input;
            parameter[6].Value = model.Uprovince;
            parameter[6].Direction = ParameterDirection.Input;
            parameter[7].Value = model.Ucity;
            parameter[7].Direction = ParameterDirection.Input;
            parameter[8].Direction = ParameterDirection.ReturnValue;
            return DbHelper.RunProcedure("ProUserinformationAdd", parameter);
        }
        /// <summary>
        /// 用户信息 修改
        /// </summary>
        /// <param name="model">用户信息实体</param>
        /// <returns>是否执行成功</returns>
        public bool UserInformationUpdate(MODEL.UserInformation model)
        {
            SqlParameter[] parameter ={new SqlParameter("@uid",SqlDbType.VarChar,15),
                                       new SqlParameter("@nickname",SqlDbType.VarChar,50),
                                       new SqlParameter("@sex",SqlDbType.Bit),
                                       new SqlParameter("@qq",SqlDbType.VarChar,20),
                                       new SqlParameter("@email",SqlDbType.VarChar,100),
                                       new SqlParameter("@tel",SqlDbType.VarChar,20),
                                       new SqlParameter("@province",SqlDbType.VarChar,20),
                                       new SqlParameter("@city",SqlDbType.VarChar,20),
                                       new SqlParameter("@Return",SqlDbType.Int)};
            parameter[0].Value = model.UID;
            parameter[0].Direction = ParameterDirection.Input;
            parameter[1].Value = model.UnickName;
            parameter[1].Direction = ParameterDirection.Input;
            parameter[2].Value = model.Usex;
            parameter[2].Direction = ParameterDirection.Input;
            parameter[3].Value = model.Uqq;
            parameter[3].Direction = ParameterDirection.Input;
            parameter[4].Value = model.Uemail;
            parameter[4].Direction = ParameterDirection.Input;
            parameter[5].Value = model.Utel;
            parameter[5].Direction = ParameterDirection.Input;
            parameter[6].Value = model.Uprovince;
            parameter[6].Direction = ParameterDirection.Input;
            parameter[7].Value = model.Ucity;
            parameter[7].Direction = ParameterDirection.Input;
            parameter[8].Direction = ParameterDirection.ReturnValue;
            return DbHelper.RunProcedure("ProUserinformationUpdate", parameter);
        }
        /// <summary>
        /// 用户信息 列表
        /// </summary>
        /// <returns>列表</returns>
        public DataSet UserInformationList()
        {
            return DbHelper.RunProcedure("ProUserinformationSelectAll");
        }
        /// <summary>
        /// 用户信息 是否以存在信息
        /// </summary>
        /// <param name="userId">用户编号</param>
        /// <returns>是否存在</returns>
        public bool CheckUserInformation(string userId)
        {
            bool flag = false;
            string sqlStr = "SELECT * FROM g_userinformation WHERE Uid=" + userId;
            DataSet ds = DbHelper.Query(sqlStr);
            if (ds.Tables[0].Rows.Count > 0)
            {
                flag = true;
            }
            else 
            {
                flag = false;
            }
            return flag;
        }
        /// <summary>
        /// 用户信息 实体
        /// </summary>
        /// <param name="uId">用户编号</param>
        /// <returns>实体</returns>
        public MODEL.UserInformation GetUserInformationModel(string uId)
        {
            SqlParameter[] parameter = { new SqlParameter("@uid", SqlDbType.VarChar, 15) };
            parameter[0].Value = uId;
            parameter[0].Direction = ParameterDirection.Input;
            DataSet ds = DbHelper.RunProcedureS("ProUserinformationSelectByUid", parameter);
            MODEL.UserInformation model = new MODEL.UserInformation();
            if (ds.Tables[0].Rows.Count > 0)
            {
                model.Ucity = ds.Tables[0].Rows[0]["Ucity"].ToString();
                model.Uemail = ds.Tables[0].Rows[0]["Uemail"].ToString();
                model.UID = ds.Tables[0].Rows[0]["Uid"].ToString();
                model.UnickName = ds.Tables[0].Rows[0]["UnickName"].ToString();
                model.Uprovince = ds.Tables[0].Rows[0]["Uprovince"].ToString();
                model.Uqq = ds.Tables[0].Rows[0]["Uqq"].ToString();
                model.UregTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["UregTime"]);
                model.Usex = Convert.ToBoolean(ds.Tables[0].Rows[0]["Usex"]);
                model.Utel = ds.Tables[0].Rows[0]["Utel"].ToString();
            }
            else
            {
                model.Ucity = "null";
                model.Uemail = "null";
                model.UID = "null";
                model.UnickName = "null";
                model.Uprovince = "null";
                model.Uqq = "null";
                model.UregTime = DateTime.Now;
                model.Usex = true;
                model.Utel = "null";
            }
            return model;
        }
    }
}